package com.ruoyi.mes.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author：coderChen date：2024/5/6 21:19
 * description：
 */
public class CodeUtils {
    /**
     * 产品编码前缀
     */
    private static final String PROSN = "CP-";
    /**
     * BOM编码前缀
     */
    private static final String BOMSN = "BOM-";
    /**
     * 设备编码前缀
     */
    private static final String EPTSN = "SB-";
    //物料编码前缀
    private static  final String MATSN = "MT-";
    //客户编码前缀
    private  static final String CUST = "CT-";
    //工序编码前缀
    private static final String PROCESS = "PC-";
    //销售订单前缀
    private static final String ORDER = "Order-";
    //工艺编号前缀
    private static final String CRAFT = "GY-";

    //生产计划编号前缀
    private static final String PLAN = "Plan-";

    //发货单号前缀
    private static final String DEVI = "Devi-";

    //库房编号前缀
    private static final String WHAREHOUSE = "WH-";
    //供应商编号前缀
    private static final String SUPPLIER = "SP-";
    //物料计划编号前缀
    private static final String MATERIAL = "MAT-";
    //车间任务编号前缀
    private static final String WKSPTASK = "WT-";
    //入库单编号前缀
    private static final String STORAGEPUT = "PUT-";
    //出库单编号前缀
    private static final String STORAGEOUT = "OUT-";
    //采购订单编号前缀
    private static final String PURCHASE = "PHE-";

    /**
     * 编码时间格式
     */
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");

    /**
     * 根据当前时间自动生成 产品编号
     */
    public static String ProCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(PROSN);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 BOM编号
     */
    public static String BomCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(BOMSN);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 设备编号
     */
    public static String EptCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(EPTSN);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 物料编号
     */
    public static String MatCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(MATSN);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 客户编号
     */
    public static String CustomerCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(CUST);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
    /**
     * 根据当前时间自动生成 工序编号
     */
    public static String ProcessCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(PROCESS);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
    /**
     * 根据当前时间自动生成 销售订单编号
     */
    public static String OrderCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(ORDER);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
    /**
     * 根据当前时间自动生成 工艺编号
     */
    public static String CraftCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(CRAFT);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 生产计划编号
     */
    public static String planCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(PLAN);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 发货单号
     */
    public static String deliverCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(DEVI);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 仓库编号
     */
    public static String whareHouseCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(WHAREHOUSE);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
    /**
     * 根据当前时间自动生成 供应商编号
     */
    public static String supplierCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(SUPPLIER);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 物料计划编号
     */
    public static String materialCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(MATERIAL);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 车间任务编号
     */
    public static String wkspTaskCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(WKSPTASK);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 入库单编号
     */
    public static String storagePutCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(STORAGEPUT);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
    /**
     * 根据当前时间自动生成 出库单编号
     */
    public static String storageOutCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(STORAGEOUT);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }

    /**
     * 根据当前时间自动生成 采购订单编号
     */
    public static String purchaseOrderCodeCreat() {
        LocalDateTime date = LocalDateTime.now();
        StringBuilder builder = new StringBuilder(PURCHASE);
        builder.append(date.format(FORMATTER));
        return builder.toString();
    }
}
